package com.tz.colawallet.ui.presenter;

import com.tz.colawallet.basecode.base.BaseBiz;
import com.tz.colawallet.basecode.base.BaseRespNew;
import com.tz.colawallet.ui.biz.LoginBiz;
import com.tz.colawallet.ui.contract.LoginContract;

import javax.inject.Inject;

/**
 * Created by Administrator on 2017/10/25.
 */

public class LoginPresenter implements LoginContract.LoginPresenter {

    LoginContract.View view;
    LoginBiz biz;

    @Inject
    public LoginPresenter(LoginContract.View view) {
        this.view = view;
    }


    @Override
    public void setBiz(BaseBiz biz) {
        this.biz = (LoginBiz) biz;
    }


    @Override
    public void login(String tel, String password) {
        view.loading(true);
        biz.login(view.curContext(), tel, password, new BaseBiz.Callback<BaseRespNew>() {
            @Override
            public void onSuccess(BaseRespNew o) {
                view.loginSuccess(o.getData());
                view.loading(false);
            }

            @Override
            public void onFailure(BaseRespNew o) {
                view.showMsg(o.getMsg());
                view.loading(false);
            }
        });
    }


}
